#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

typedef pair<int, int> P;

const int N = 1e5 + 500;

P a[N], b[N];

bool solve(P a[], P b[], int n)
{
	dbg("play");
	static set<P> S;
	static set<P, greater<P>> smax;
	static set<P> emin;

	static P e[N << 2];
	static int ecnt;

	S.clear();
	smax.clear();
	emin.clear();

	ecnt = 0;
	for (int i = 0; i < n; ++i)
	{
		e[ecnt++] = make_pair(a[i].first, i);
		e[ecnt++] = make_pair(a[i].second + 1, -i-1);
	}

	sort(e, e + ecnt);

	for (int i = 0; i < ecnt; ++i)
	{
		if (e[i].second >= 0)
		{
			int id = e[i].second;
			dbg(i, e[i].first, smax.size(), emin.size());
		
			if (smax.size() && emin.size())
			{

				dbg(i, id, e[i].first, smax.begin()->first);
				bool judge = smax.begin()->first <= b[id].second && emin.begin()->first >= b[id].first;
				if (!judge)
				{
					dbg(id, smax.begin()->first, b[id].second, emin.begin()->first, b[id].first);
					return false;
				}
			}

			smax.emplace(b[id].first, id);
			emin.emplace(b[id].second, id);
		}
		else
		{
			int id = -e[i].second-1;
			smax.erase(P(b[id].first, id));
			emin.erase(P(b[id].second, id));
		}
	}
	return true;
}

int n;

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d%d%d", &a[i].first, &a[i].second, &b[i].first, &b[i].second);
	if (solve(a, b, n) && solve(b, a, n))
		puts("YES");
	else
		puts("NO");
	return 0;
}